<?php

use think\Route;



//\mogoSDK\util\RouteRule::run();

//include_once __DIR__.'/thinkSDK.php';
//use ThinkSDKRouter;
//RouteRule::run();
// 资源控制器 restful
//ThinkSDKRouter\Rule::run();
Route::resource('sign','demo/sign');
// 功能控制器
Route::post('v2/comment','xiaoan/comment/saveV2');





// 魔工评论注册路由 ------------------------------------------
Route::resource('mogo/comments','mogo/comments');
Route::post('mogo/comments/:id/like','mogo/comments/like');
Route::resource('mogo/message','mogo/message');
Route::rule('mogo/comments/my','mogo/comments/my');
// 魔工评论注册路由 ------------------------------------------

// 下面是讲课的内容

Route::get('api/config','mogo/config/index');

//
//CURD 用户  创建 修改 读取 删除
//Route::post('api/user','mogo/user/save');
//Route::post('api/user/:id/edit','mogo/user/save');
//Route::post('api/user/:id/rePsw','mogo/user/rePassword');
//Route::post('api/user/:id/reTel','mogo/user/rePassword');

//Route::get('api/user','mogo/user/rePassword');
Route::get('api/user/:id','mogo/user/read');
Route::delete('api/user/:id','mogo/user/delete');
// POST GET DELETE

Route::get('api/version',function(){
    echo config('admin_base_layout');
});




Route::get('api/config','mogo/config/index');

//
//CURD 用户  创建 修改 读取 删除
Route::post('api/user','mogo/user/save');
//Route::post('api/user/:id/edit','mogo/user/save');
//Route::post('api/user/:id/rePsw','mogo/user/rePassword');
//Route::post('api/user/:id/reTel','mogo/user/rePassword');

Route::get('api/user','mogo/user/index');
Route::get('api/user/:id','mogo/user/read');
Route::delete('api/user/:id','mogo/user/delete');
// POST GET DELETE

Route::get('api/version',function(){
    $plan = new \app\xdk\model\Plan();
    $res = $plan->paginate();
    return json($res);
});

Route::post('xdk/plan','xdk/plan/save');
Route::post('xdk/plan/:id/fav','xdk/plan/fav');
Route::post('xdk/plan/:id/comments','xdk/plan/comments'); //推荐


Route::post('xdk/tags','xdk/tags/save');
Route::post('xdk/sign','xdk/sign/save');
Route::post('xdk/comments','xdk/comments/save');


use Intervention\Image\ImageManagerStatic as Image;
Route::get('poster',function(){
    $Qiniu = new  \plugins\QiNiu\QiNiu;
    Image::configure(array('driver' => 'imagick'));

    $img = Image::make('http://p1i6qu8hf.bkt.clouddn.com/icecreamlove_1x.png');
    $img->text('人民共和国万岁啦', 400/2, 300/2+300/2/2+50, function($font) {
        $font->file('./ping.ttf');
        $font->size(36);
        $font->color('#1abc9c');
        $font->align('center');
//        $font->valign('top');
    });
    $img->text('只要20元哦', 400/2, 50, function($font) {
        $font->file('./ping.ttf');
        $font->size(50);
        $font->color('#1abc9c');
        $font->align('center');
//        $font->valign('top');
    });
    $img->insert('https://gitee.com/index/ent_poster/banner_5_2_a.png', 'bottom-right', 10, 10);
//    $img->resize(750/2,1334/2);
    $img->encode();
//    $img->widen(300);

    $ret =  $Qiniu->uploadUseFileString($img);
//    $Qiniu->upload
    echo "<img src='{$ret['url']}' />";
});


Route::miss(function(){
    return json(['error'=>'resource or method not find'],404);
});



//以下为sdk路由
//Route::post('demo/plan','demo/plan/addPlan');